export default {
    data: {
        interval: null, // 定时器对象
        showText: true, // 是否显示文本
        textOn: '动态',
        textOff: '静态',
        allowScale: true, // 文本尺寸跟随系统设置字体缩放
        dataLength: 5, // 数据长度
        barGroup: 3, // 柱状图组数

        loadingData: null, // 线形图数据
        loadingSegments: null,

        progressSegments: {},

        rainbowSegments: [],

        colors: [
            {
                startColor: "#f7ce00",
                endColor: "#f99b11",
            },
            {
                startColor: "#f76223",
                endColor: "#f2400a",
            },
            {
                startColor: "#f772ac",
                endColor: "#e65392",
            },
            {
                startColor: "#a575eb",
                endColor: "#a12df7",
            },
            {
                startColor: "#7b79f7",
                endColor: "#4b48f7",
            },
            {
                startColor: "#4b8af3",
                endColor: "#007dff",
            },
            {
                startColor: "#73c1e6",
                endColor: "#4fb4e3",
            },
            {
                startColor: "#a5d61d",
                endColor: "#69d14f",
            },
            {
                startColor: "#a2a2b0",
                endColor: "#8e8e93",
            }
        ]
    },
// 初始化
    onReady() {
        setTimeout(() => {
            this.changeLoading(); // 更新加载类圆形图表
            this.changeProgress(); // 更新进度类圆形图表
            this.changeRainbow(); // 更新占比类圆形图表
        }, 0)
    },
    change(e) {
        if (e.checked) {
            this.interval = setInterval(() => {
                this.changeLoading(); // 更新加载类圆形图表
                this.changeProgress(); // 更新进度类圆形图表
                this.changeRainbow(); // 更新占比类圆形图表
            }, 3000)
        } else {
            clearInterval(this.interval);
        }
    },
// 更新加载类圆形图表
    changeLoading() {
        const index = Math.floor((Math.random() * 9))
        console.log(index)
        this.loadingSegments = this.colors[index]
        console.log(JSON.stringify(this.loadingSegments))
    },
// 更新进度类圆形图表
    changeProgress() {
        const index = Math.floor((Math.random() * 9))
        const value = Math.ceil((Math.random() * 100))
        console.log(index)
        const progressSegments = this.colors[index]
        progressSegments.value = value
        this.progressSegments = progressSegments;
    },
// 更新占比类圆形图表
    changeRainbow() {
        const num = Math.floor((Math.random() * 2 + Math.random() * 7))
        console.log("aaaa" + num)
        const list = []
        for (let i = 0; i < num; i++) {
            const index = Math.floor((Math.random() * 9))
            const value = Math.ceil((Math.random() * (100 / num)))
            const data = this.colors[index]
            data.value = value
            data.name = value
            list.push(data)
        }
        this.rainbowSegments = list
    }
}